/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.security.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Obama
 */
@Entity
@Table(name = "SECURITY_RESOURCE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SecurityResource.findAll", query = "SELECT s FROM SecurityResource s"),
    @NamedQuery(name = "SecurityResource.findByResourceId", query = "SELECT s FROM SecurityResource s WHERE s.resourceId = :resourceId"),
    @NamedQuery(name = "SecurityResource.findByResourceName", query = "SELECT s FROM SecurityResource s WHERE s.resourceName = :resourceName"),
    @NamedQuery(name = "SecurityResource.findByResourceCode", query = "SELECT s FROM SecurityResource s WHERE s.resourceCode = :resourceCode"),
    @NamedQuery(name = "SecurityResource.findByCreatorName", query = "SELECT s FROM SecurityResource s WHERE s.creatorName = :creatorName"),
    @NamedQuery(name = "SecurityResource.findByResource", query = "SELECT s FROM SecurityResource s WHERE s.resource = :resource"),
    @NamedQuery(name = "SecurityResource.findByCreatorTime", query = "SELECT s FROM SecurityResource s WHERE s.creatorTime = :creatorTime"),
    @NamedQuery(name = "SecurityResource.findByResourceState", query = "SELECT s FROM SecurityResource s WHERE s.resourceState = :resourceState"),
    @NamedQuery(name = "SecurityResource.findByUpdaterName", query = "SELECT s FROM SecurityResource s WHERE s.updaterName = :updaterName"),
    @NamedQuery(name = "SecurityResource.findByUpdateTime", query = "SELECT s FROM SecurityResource s WHERE s.updateTime = :updateTime"),
    @NamedQuery(name = "SecurityResource.findByRefId", query = "SELECT s FROM SecurityResource s WHERE s.refId = :refId"),
    @NamedQuery(name = "SecurityResource.findByRefType", query = "SELECT s FROM SecurityResource s WHERE s.refType = :refType"),
    @NamedQuery(name = "SecurityResource.findByResourceDesc", query = "SELECT s FROM SecurityResource s WHERE s.resourceDesc = :resourceDesc"),
    @NamedQuery(name = "SecurityResource.findByPicRef", query = "SELECT s FROM SecurityResource s WHERE s.picRef = :picRef"),
    @NamedQuery(name = "SecurityResource.findByCallMode", query = "SELECT s FROM SecurityResource s WHERE s.callMode = :callMode"),
    @NamedQuery(name = "SecurityResource.findByCallType", query = "SELECT s FROM SecurityResource s WHERE s.callType = :callType")})
public class SecurityResource implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "RESOURCE_ID")
    private String resourceId;
    @Size(max = 30)
    @Column(name = "RESOURCE_NAME")
    private String resourceName;
    @Size(max = 20)
    @Column(name = "RESOURCE_CODE")
    private String resourceCode;
    @Size(max = 20)
    @Column(name = "CREATOR_NAME")
    private String creatorName;
    @Size(max = 200)
    @Column(name = "RESOURCE")
    private String resource;
    @Column(name = "CREATOR_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creatorTime;
    @Size(max = 1)
    @Column(name = "RESOURCE_STATE")
    private String resourceState;
    @Size(max = 20)
    @Column(name = "UPDATER_NAME")
    private String updaterName;
    @Column(name = "UPDATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    @Size(max = 32)
    @Column(name = "REF_ID")
    private String refId;
    @Size(max = 20)
    @Column(name = "REF_TYPE")
    private String refType;
    @Size(max = 200)
    @Column(name = "RESOURCE_DESC")
    private String resourceDesc;
    @Size(max = 200)
    @Column(name = "PIC_REF")
    private String picRef;
    @Size(max = 200)
    @Column(name = "CALL_MODE")
    private String callMode;
    @Size(max = 200)
    @Column(name = "CALL_TYPE")
    private String callType;
    @OneToMany(mappedBy = "fatherId")
    private List<SecurityResource> securityResourceList;
    @JoinColumn(name = "FATHER_ID", referencedColumnName = "RESOURCE_ID")
    @ManyToOne
    private SecurityResource fatherId;
    @OneToMany(mappedBy = "resourceId")
    private List<SecurityPermission> securityPermissionList;

    public SecurityResource() {
    }

    public SecurityResource(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getResourceName() {
        return resourceName;
    }

    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    public String getResourceCode() {
        return resourceCode;
    }

    public void setResourceCode(String resourceCode) {
        this.resourceCode = resourceCode;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    public Date getCreatorTime() {
        return creatorTime;
    }

    public void setCreatorTime(Date creatorTime) {
        this.creatorTime = creatorTime;
    }

    public String getResourceState() {
        return resourceState;
    }

    public void setResourceState(String resourceState) {
        this.resourceState = resourceState;
    }

    public String getUpdaterName() {
        return updaterName;
    }

    public void setUpdaterName(String updaterName) {
        this.updaterName = updaterName;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getRefId() {
        return refId;
    }

    public void setRefId(String refId) {
        this.refId = refId;
    }

    public String getRefType() {
        return refType;
    }

    public void setRefType(String refType) {
        this.refType = refType;
    }

    public String getResourceDesc() {
        return resourceDesc;
    }

    public void setResourceDesc(String resourceDesc) {
        this.resourceDesc = resourceDesc;
    }

    public String getPicRef() {
        return picRef;
    }

    public void setPicRef(String picRef) {
        this.picRef = picRef;
    }

    public String getCallMode() {
        return callMode;
    }

    public void setCallMode(String callMode) {
        this.callMode = callMode;
    }

    public String getCallType() {
        return callType;
    }

    public void setCallType(String callType) {
        this.callType = callType;
    }

    @XmlTransient
    public List<SecurityResource> getSecurityResourceList() {
        return securityResourceList;
    }

    public void setSecurityResourceList(List<SecurityResource> securityResourceList) {
        this.securityResourceList = securityResourceList;
    }

    public SecurityResource getFatherId() {
        return fatherId;
    }

    public void setFatherId(SecurityResource fatherId) {
        this.fatherId = fatherId;
    }

    @XmlTransient
    public List<SecurityPermission> getSecurityPermissionList() {
        return securityPermissionList;
    }

    public void setSecurityPermissionList(List<SecurityPermission> securityPermissionList) {
        this.securityPermissionList = securityPermissionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (resourceId != null ? resourceId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SecurityResource)) {
            return false;
        }
        SecurityResource other = (SecurityResource) object;
        if ((this.resourceId == null && other.resourceId != null) || (this.resourceId != null && !this.resourceId.equals(other.resourceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.herenit.beijing.dh2011.security.SecurityResource[ resourceId=" + resourceId + " ]";
    }
    
}
